<!DOCTYPE HTML>
<title>Test devicechange event</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>

async_test(test => {
  assert_idl_attribute(navigator, 'mediaDevices');
  assert_idl_attribute(navigator.mediaDevices, 'enumerateDevices');
  assert_idl_attribute(navigator.mediaDevices, 'ondevicechange');

  navigator.mediaDevices.addEventListener("devicechange", test.step_func_done(function() {}));

  // force device change by adding a fake device.
  // Note: Fake devices don't trigger devicechange events yet,
  // so this will time out. Instead, let it fail for now.
  // crbug.com/678561
  internals.addFakeDevice({kind: "video"}, {})
      .catch(function(e) {
    console.log('Fake devices are not functional yet.');
    assert_equals(e.name, 'TypeError', 'Check crbug.com/678561');
    // Question for reviewer: Is it better to have the test fail for now?
    test.done();
  });

});

</script>
